using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Xml;
using System.Web;
using System.Web.Services;
using Dimok;
using Dimok.Exceptions;
using Dimok.Data;
using Dimok.Data.Database;

namespace Dimok.Menu.Admin {

	////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>	Summary description for Admin. </summary>
	///
	/// <remarks>	Dimon, 12/21/2010. </remarks>
	////////////////////////////////////////////////////////////////////////////////////////////////////

	public class WS : System.Web.Services.WebService{
		protected Dimok.Data.UserObjectEx uox;

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Default constructor. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public WS() {
			//CODEGEN: This call is required by the ASP.NET Web Services Designer
			InitializeComponent();
			uox = new Dimok.Data.UserObjectEx();
		}

		#region Component Designer generated code
		
		//Required by the Web Services Designer 
		private IContainer components = null;

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	
		/// Required method for Designer support - do not modify the contents of this method with the code
		/// editor. 
		/// </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		private void InitializeComponent() {
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Clean up any resources being used. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="disposing">	true if resources should be disposed, false if not. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		protected override void Dispose( bool disposing ) {
			if(disposing && components != null) {
				components.Dispose();
			}
			base.Dispose(disposing);		
		}
		
		#endregion

		// WEB SERVICE EXAMPLE
		// The HelloWorld() example service returns the string Hello World
		// To build, uncomment the following lines then save and build the project
		// To test this web service, press F5

		#region MenuGroups ================

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets a menu tree. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="groupName">	Name of the group. </param>
		///
		/// <returns>	The menu tree. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string GetMenuTree(string groupName){
			try{
				if( Config.application.AppSpace == "AFC" )
					return XmlEx.GetLevelsXml(this.uox.db, "SELECT Text,MenuID,ParentMenuID FROM vx_MenuForTree WHERE 1=1", "MenuID", "ParentMenuID", "MYTREE", "TREENODE");
				return	XmlEx.GetLevelsXml(uox.db,"SELECT Text,MenuID,ParentMenuID FROM MenuForTree(@Group) ORDER BY StateFlowPos","MenuID","ParentMenuID","MYTREE","TREENODE",new SqlParameter("@Group",groupName));
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu groups get. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="nameSpace">		The name space. </param>
		/// <param name="menuID">				Identifier for the menu. </param>
		/// <param name="groupFilter">	The group filter. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string MenuGroups_Get(string nameSpace,int menuID,string groupFilter){
			try{
				//throw new ClientException("NameSpace:"+nameSpace);
				string sql = "EXEC sp__sec_MenuGroups_UI @MenuID,@NameSpace,@Groups";
//"SELECT GroupName,Access FROM t_Menu_Group WHERE MenuID=@MenuID;" +
//					"SELECT GroupName,AccessID,Checked,AccessName FROM vx_MenuGroupAccess_Detailed WHERE MenuID=@MenuID";
				DataSet ds = SQLHelperEx.ExecuteDatasetEx(uox.db, sql, menuID, MenuGroupNameSpace(nameSpace),
					uox.GetAllGroupsInNamespace(
					groupFilter + "" != "" ? "^" + groupFilter + "$" : null).GetXml());
				ds.Tables[1].TableName = "AccessList";
				ds.Relations.Add("REL",ds.Tables[0].Columns["GroupName"],ds.Tables[1].Columns["GroupName"]).Nested = true;
				return ds.GetXml();
			}catch(Exception exc){ throw new ClientException(exc,(NameValueCollection)new NameValueCollectionEx("MenuID",menuID+"")); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu group add. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="nameSpace">	The name space. </param>
		/// <param name="groupName">	Name of the group. </param>
		/// <param name="menuID">			Identifier for the menu. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void MenuGroup_Add(string nameSpace,string groupName,int menuID){
			try{
				SQLHelperEx.ExecuteNonQueryEx(uox.db,
					"INSERT INTO t_Menu_Group(MenuID,GroupName,NameSpace) VALUES(@MenuID,@Group,@NameSpace)",menuID,groupName,MenuGroupNameSpace(nameSpace));
			}catch(Exception exc){throw new ClientException(exc);}
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu group rem. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="nameSpace">	The name space. </param>
		/// <param name="groupName">	Name of the group. </param>
		/// <param name="menuID">			Identifier for the menu. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void MenuGroup_Rem(string nameSpace,string groupName,int menuID){
			try{
				SQLHelperEx.ExecuteNonQueryEx(uox.db,"DELETE FROM t_Menu_Group WHERE MenuID=@MenuID AND GroupName=@Group AND NameSpace=@NS",menuID,groupName,MenuGroupNameSpace(nameSpace));
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu group update. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="nameSpace">	The name space. </param>
		/// <param name="groupName">	Name of the group. </param>
		/// <param name="menuID">			Identifier for the menu. </param>
		/// <param name="access">			The access. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public int MenuGroup_Update(string nameSpace,string groupName,int menuID,int access){
			try{
				return (int)SQLHelperEx.ExecuteScalarEx(uox.db,@"
UPDATE t_Menu_Group SET Access=@Access WHERE MenuID=@MenuID AND GroupName=@Group AND NameSpace=@NS;
SELECT Access FROM t_Menu_Group WHERE MenuID=@MenuID AND GroupName=@Group AND NameSpace=@NS",access,menuID,groupName,MenuGroupNameSpace(nameSpace));
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	State group update. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="nameSpace">	The name space. </param>
		/// <param name="groupName">	Name of the group. </param>
		/// <param name="stateID">		Identifier for the state. </param>
		/// <param name="accessID">		Identifier for the access. </param>
		/// <param name="add">				true to add. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void StateGroup_Update(string nameSpace, string groupName, int stateID, int accessID,bool add) {
			try {
				string sql = "SELECT * FROM t_State_Group_Access WHERE StateID = @SID AND principal_id = @PID AND StateAccessID = @SAID";
				DataTable dt = new DataTable();
				dt.Columns.Add("StateID",typeof(int));
				dt.Columns.Add("principal_id",typeof(string));
				dt.Columns.Add("StateAccessID",typeof(int));
				if( add )dt.Rows.Add(stateID,groupName,accessID);
				SQLHelperEx.UpdateDataTable(dt, uox.db, sql, stateID, groupName, accessID);
			} catch (Exception exc) { throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu group name space. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="nameSpace">	The name space. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		private string MenuGroupNameSpace(string nameSpace){
			return uox.NameSpace+(nameSpace==""?"":UserObjectEx.NAMESPACE_DIVIDER+nameSpace);
		}
		#endregion MenuGroups <<<<<<<<<<<<<

		#region Workflow ================

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf actions update. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="fieldName">	Name of the field. </param>
		/// <param name="fieldValue">	The field value. </param>
		/// <param name="eventID">		Identifier for the event. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_Actions_Update(string fieldName, string fieldValue, int eventID){
			try{
				SQLHelperEx.UpdateDataTable(new HashTableEx(fieldName,fieldValue),
					uox.db,"SELECT EventID,"+fieldName+" FROM t_MenuEvent WHERE EventID=@EID",eventID);
				return eventID == 0 && Regex.IsMatch(fieldName,"menu",RegexOptions.IgnoreCase) && fieldValue != null ?
					WF_Actions(int.Parse(fieldValue)) : "";
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf actions delete. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="eventID">	Identifier for the event. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void WF_Actions_Delete(int eventID){
			try{
				SQLHelperEx.ExecuteDatasetEx(uox.db,"DELETE t_MenuEvent WHERE EventID=@EID",eventID);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf actions. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">	Identifier for the menu. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_Actions(int menuID){
			try{
				return SQLHelperEx.XmlInnerText(uox.db,uox.MenuEventsSQL(menuID),true);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf list. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="statusNameSpace">	The status name space. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_List(string statusNameSpace){
			try{
				return uox.WorkFlowList(statusNameSpace).GetXml();
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf tree. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="statusNameSpace">	The status name space. </param>
		/// <param name="groupName">				Name of the group. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_Tree(string statusNameSpace,string groupName){
			try{
				return uox.WorkFlowTree(statusNameSpace,groupName);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets the wf get. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_Get(){
			try{
				return SQLHelperEx.ADOToString(uox.dbADO,"SELECT MenuID,NextMenuID,MenuPath,NextMenuPath FROM v_WorkFlow");
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets the wfg get. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WFG_Get(){
			try{
				return SQLHelperEx.ADOToString(uox.dbADO,"SELECT MenuID,MenuToID,MenuPath,MenuToPath,GroupName FROM v_WorkFlow_Groups");
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf add. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuFromID">	Identifier for the menu from. </param>
		/// <param name="menuToID">		Identifier for the menu to. </param>
		/// <param name="groupName">	Name of the group. </param>
		/// <param name="addAccess">	true to add access. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_Add(int menuFromID,int menuToID,string groupName,bool addAccess){
			try{
				SQLHelperEx.ExecuteScalarEx(uox.db,"INSERT INTO t_WorkFlow(MenuID,NextMenuID) VALUES(@MenuFromID,@MenuToID)",menuFromID,menuToID);
				if( addAccess )return WFG_Add(menuFromID,menuToID,groupName);
				return uox.WorkFlowTree(menuFromID,groupName);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wfg add. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuFromID">	Identifier for the menu from. </param>
		/// <param name="menuToID">		Identifier for the menu to. </param>
		/// <param name="groupName">	Name of the group. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WFG_Add(int menuFromID,int menuToID,string groupName){
			try{
				SQLHelperEx.ExecuteScalarEx(uox.db,"INSERT INTO t_WorkFlow_Groups SELECT @MenuFromID,@MenuToID,@GroupName",menuFromID,menuToID,groupName);
				return uox.WorkFlowTree(menuFromID,groupName);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wf rem. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">			Identifier for the menu. </param>
		/// <param name="nextMenuID">	Identifier for the next menu. </param>
		/// <param name="groupName">	Name of the group. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WF_Rem(int menuID,int nextMenuID,string groupName){
			try{
				SQLHelperEx.ExecuteScalarEx(uox.db,"DELETE FROM t_WorkFlow WHERE MenuID=@MenuID AND NextMenuID=@NextMenuID",menuID,nextMenuID);
				return uox.WorkFlowTree(menuID,groupName);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Wfg rem. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">			Identifier for the menu. </param>
		/// <param name="nextMenuID">	Identifier for the next menu. </param>
		/// <param name="groupName">	Name of the group. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string WFG_Rem(int menuID,int nextMenuID,string groupName){
			try{
				SQLHelperEx.ExecuteScalarEx(uox.db,"DELETE FROM t_WorkFlow_Groups WHERE MenuID=@MenuID AND NextMenuID=@NextMenuID AND GroupName=@GroupName",menuID,nextMenuID,groupName);
				return uox.WorkFlowTree(menuID,groupName);
			}catch(Exception exc){ throw new ClientException(exc); }
		}
		#endregion WorkFlow <<<<<<<<<<<<<<<<

		#region Menu Pages ================

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets the get. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string MP_Get(){
			try{
				return SQLHelperEx.ADOToString(uox.dbADO, "SELECT * FROM v_Menu_Pages_NameSpace");
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Rem. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="id">	The identifier. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void MP_Rem(int id){
			try{
				SQLHelperEx.ExecuteScalarEx(uox.db, "DELETE FROM " + Config.Menu.Menu_Pages_NameSpace + " WHERE ID=@ID", id);
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Add. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">				Identifier for the menu. </param>
		/// <param name="pageID">				Identifier for the page. </param>
		/// <param name="tabIndex">			Zero-based index of the tab. </param>
		/// <param name="pageTypeID">		Identifier for the page type. </param>
		/// <param name="parentMenuID">	Identifier for the parent menu. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void MP_Add(int menuID,int pageID,int tabIndex,string pageTypeID,int parentMenuID){
			try{
				object PTID = System.DBNull.Value;
				if( pageTypeID !="" )PTID = (object)int.Parse(pageTypeID);
				SQLHelperEx.ExecuteScalarEx(uox.db, "INSERT INTO v_Menu_Pages_NameSpace(MenuID,PageID,TabIndex,PageTypeID,ParentMenuID) VALUES(@MenuID,@PageID,@TabIndex,@PageTypeID,@ParentMenuID)", menuID, pageID, tabIndex, PTID, parentMenuID);
			}catch(Exception exc){ throw new ClientException(exc); }
		}
		#endregion Menu Pages <<<<<<<<<<<<<

		#region Menus

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Gets the menu list. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public string Menu_List() {
			try{
				return SQLHelperEx.ADOToString(uox.dbADO,"SELECT * FROM t_Menu");
			}catch(Exception exc){ throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu update. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">			Identifier for the menu. </param>
		/// <param name="fieldName">	Name of the field. </param>
		/// <param name="fieldValue">	The field value. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void Menu_Update(int menuID,string fieldName,object fieldValue) {
			try {
				SQLHelperEx.UpdateField(uox.db, "SELECT * FROM t_Menu WHERE MenuID=" + menuID, fieldName, fieldValue);
			} catch (Exception exc) { throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu delete. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">	Identifier for the menu. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void Menu_Delete(int menuID) {
			try{
			SQLHelperEx.ExecuteNonQueryEx(uox.db,"DELETE FROM t_Menu WHERE MenuID="+menuID);
			} catch (Exception exc) { throw new ClientException(exc); }
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Menu add. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="dsMenu">	Element describing the ds menu. </param>
		///
		/// <returns>	. </returns>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public int Menu_Add(XmlElement dsMenu) {
			try{
				DataTable dt = SQLHelperEx.LoadDataTable(dsMenu);
				SQLHelperEx.UpdateDataTable(dt,uox.db,"SELECT TOP 0 * FROM t_Menu");
				return (int)SQLHelperEx.ExecuteScalarEx(uox.db,"SELECT MenuID FROM t_Menu WHERE MenuLable=@MenuLable",dt.Rows[0]["MenuLable"]);
			}catch( Exception exc ){ throw new ClientException(exc); }
		}
		#endregion

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Sends to menu. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <exception cref="ClientException">	Thrown when client. </exception>
		///
		/// <param name="menuID">	Identifier for the menu. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		[WebMethod]
		public void SendToMenu(int menuID){
			try{
				uox.LockApplicant();
				uox.menuID = menuID;
			}catch(Exception exc){throw new ClientException(exc);}
		}

	}
}
